/*=============================================================================
*
*   Copyright (C) 2020 All rights reserved.
*
*   Filename:		mod.rs
*
*   Author: Wang Zhecheng - wangzhecheng@yeah.net
*
*   Date: 2020-09-23 22:02
*
*   Last Editors: Wang Zhecheng - wangzhecheng@yeah.net
*
*   Last modified:	2020-11-06 18:27
*
*   Description:
*
=============================================================================*/
pub mod integratable;
// pub mod mesh;
pub mod point;
pub mod shape;
// pub mod shape_function;

// use crate::dimension::TwoDimension;
// use crate::geometry::shape::point::PointLike;
use crate::Real;
// use nalgebra::dimension::{U2, U3};

pub enum Side {
    Left(Real),
    Right(Real),
}

// #[inline]
// fn anti_clock_angle(
//     p1: &impl PointLike<TwoDimension<R1 = U3, R2 = U2>>,
//     p2: &impl PointLike<TwoDimension<R1 = U3, R2 = U2>>,
// ) -> Real
// where
//     TwoDimension<R1 = U3, R2 = U2>: Sized,
// {
//     (p2.y() - p1.y()).atan2(p2.x() - p1.x())
// }
// #[inline]
// fn if_at_left_wing(
//     p0: &impl PointLike<TwoDimension<R1 = U3, R2 = U2>>,
//     p1: &impl PointLike<TwoDimension<R1 = U3, R2 = U2>>,
//     p: &impl PointLike<TwoDimension<R1 = U3, R2 = U2>>,
// ) -> Side {
//     let x0 = p0.x();
//     let y0 = p0.y();
//     let x1 = p1.x();
//     let y1 = p1.y();
//     let xp = p.x();
//     let yp = p.y();
//     if (x1 - x0) * (yp - y0) - (y1 - y0) * (xp - x0) > 0 as Real {
//         // 1 as Real
//         Side::Left(1 as Real)
//     } else {
//         // -1 as Real
//         Side::Right(-1 as Real)
//     }
// }

// #[test]
// fn test_anti_clock() {
//     use crate::consts::PI;
//     use crate::geometry::shape::point::Point;
//     use approx::assert_relative_eq;
//     let p0 = Point::<TwoDimension<R1 = U3, R2 = U2>>::default();
//     let p1 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(1f32, 0f32);
//     let p2 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(1f32, 1f32);
//     let p3 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(0f32, 1f32);
//     let p4 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(-1f32, 1f32);
//     let p5 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(-1f32, 0f32);
//     let p6 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(-1f32, -1f32);
//     let p7 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(0f32, -1f32);
//     let p8 = Point::<TwoDimension<R1 = U3, R2 = U2>>::new(1f32, -1f32);
//     assert_relative_eq!(anti_clock_angle(&p0, &p1), 0., max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p2), PI * 0.25, max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p3), PI * 0.5, max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p4), PI * 0.75, max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p5), PI, max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p6), PI * -0.75, max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p7), PI * -0.5, max_relative = 1e-2);
//     assert_relative_eq!(anti_clock_angle(&p0, &p8), PI * -0.25, max_relative = 1e-2);
// assert_eq!(if_at_left_wing(&p1, &p0, &p4), Side::Right);
// assert_eq!(if_at_left_wing(&p1, &p0, &p6), Side::Left);
// }
